<template>
  <button @click="startgame">开始任务</button>
</template>

<script>
import { defineComponent, ref, onMounted } from "vue";
import { useRouter } from "vue-router";
// 固定用法
export default defineComponent({
  name: "Start",
  setup() {
    let router = useRouter();
    let name = ref("jack");
    let age = ref(18);
    let obj = ref({
      name,
      age,
    });
    // 在onMounted中接收路由传递过来的参数

    onMounted(() => {
      console.log("onMounted执行了");
    });
    console.log("seTup");
    let startgame = () => {
      router.push({
        name: "Home",
        query: {
          name: name.value,
          age: age.value,
          obj: JSON.stringify(obj.value),
        },
      });
    };

    return {
      startgame,
    };
  },
});
</script>

<style scoped lang='scss'>
</style>
